updating oE allocate_protect
allocate_protect
include machine.e namespace machine public function allocate_protect(object data, memconst :valid_wordsize wordsize = 1, valid_memory_protection_constant protection)
Allocates and copies data into memory and gives it protection using Standard Library Memory Protection Constants or Microsoft Windows Memory Protection Constants. The user may only pass in one of these constants. If you only wish to execute a sequence as machine code use allocate_code. If you only want to read and write data into memory use allocate.
See MSDN: Microsoft's Memory Protection Constants
Parameters:
- data : is the machine code to be put into memory.
- wordsize : is the size each element of data will take in memory. Are they 1-byte, 2-bytes, 4-bytes or 8-bytes long? Specify here. The default is 1.
- protection : is the particular Windows protection.
Returns:
An address, The function returns the address to the required memory or 0 if it fails. This function is guaranteed to return memory on the 8 byte boundary. It also guarantees that the memory returned with at least the protection given (but you may get more).
If you want to call allocate_protect( data, PAGE_READWRITE ), you can use allocate instead. It is more efficient and simpler.
If you want to call allocate_protect( data, PAGE_EXECUTE ), you can use allocate_code instead. It is simpler.
You must not use free on memory returned from this function, instead use free_code.
See Also:
Not Categorized, Please Help
|